<?php
require('../../public/function.php');
connection('blog');
//添加分类
$fenlei=isset($_POST['colId'])?$_POST['colId']:'';
// echo $fenlei;die;


//$select=isset($_POST['colId'])?$_POST['colId']:'';//接收的下拉框值
$title=isset($_POST['title'])?$_POST['title']:'';//接收的标题名
$author=isset($_POST['author'])?$_POST['author']:'';//接收的作者名
$content=isset($_POST['content'])?$_POST['content']:'';//接收的内容
$ctime=date('Y:m:d     H:i:s');
//$img=$_POST['smallimg'];
$fid=$_POST['colId'];
//var_dump($_POST);die;






$pic=@$_FILE['smallimg'];
$alltype=array('jpg','jpeg','gif','png');
$size=999999999;
$f=explode(".",$_FILES['smallimg']['name']);
$filename=date("YmdHis").rand(100,999).'.'.(array_pop($f));
$p=move_uploaded_file($_FILES['smallimg']['tmp_name'],"D:/jiaoli/WWW/blog2/admin/theimg/$filename");
$url="/admin/theimg/$filename";
if($pic['error']>0){
switch ($_FILES["myfile"]["error"]) {
    case '1':die('文件大小超出了约定值');
    case '2':die('文件大小超出了html表单隐藏域属性的max_file_size所指定的最大值');
    case '3':die('文件只被部分上传');    
    case '4':die('没有上传任何文件');      
    case '6':die('找不到临时文件夹');    
    case '7':die('文件写入失败');    
}
}




$sql="insert into blog(title,author,category,ctime,fid,content,url) values('$title','$author','$fenlei','$ctime','$fid','$content','$url')";
$res=mysql_query($sql);
if($res){
    echo "<script>alert('添加成功！');window.location.href='../articlelist/design.php'</script>";//window.location.href='mysql.php'
}else{
    echo "<script>alert('添加失败！');window.location.href='../articlelist/design.php'</script>";
}








?>